package com.dkts.oil.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.dkts.oil.service.impl.OilAddressServiceImpl;
import com.dkts.oil.service.impl.OilAddressV2ServiceImpl;
import com.dkts.oil.web.vo.request.OilCustomTankRequest;
import com.dkts.oil.web.vo.request.OilStorageTankRequest;
import com.dkts.oil.web.vo.request.SiteSelectionRequest;
import com.dkts.oil.web.vo.response.AddressPlanResponse;
import com.dkts.oil.web.vo.response.Result;
import com.dkts.oil.web.vo.response.subReq.OilStorageAddress;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  3.1 转运站 址地相关
 * </p>
 *
 * @author heguanglong
 * @since 2025-04-10
 */
@RestController
@RequestMapping("/v2/oil/address")
@Slf4j
@Tag(name = "油库选址相关接口")
public class OilAddressV2Controller {
    @Autowired
    private OilAddressV2ServiceImpl oilAddressService;
    @Schema(description = "油库选址")
    @PostMapping("/oil/address")
    public Result<List<AddressPlanResponse.PlanItem>> oilStorage(@Validated @RequestBody SiteSelectionRequest request) throws Exception {
        long startTime = System.currentTimeMillis();
        log.info("oilStorage time:{}  request:{}",startTime, JSONObject.toJSONString(request));
        request.check();
        List<AddressPlanResponse.PlanItem> addressPlanResponses =  oilAddressService.oilStorageV2(request);
        log.info("oilStorage time:{}  countTime：{}  request:{}",startTime,System.currentTimeMillis() - startTime, JSONObject.toJSONString(addressPlanResponses));
        return Result.success(addressPlanResponses);
    }

}
